<?php

if (!defined('__BACKEND__'))
    die("you cannot directly access this page");
/*
 * by SONY K Wibisono
 * e-mail : sony@sonywibisono.com
 */
function add_form(){
    
}
function add_process(){
    
}
function edit_form(){
    
}
function edit_process(){
    
}
function delete(){
    
}
function list_table(){
    global $db,$page,$pagesize;
    if (empty($page)){
        $start=0;
    } else {
         $start=$page * $pagesize; 
    }
    $sql="select a.*,b.user_name,b.fullname ,c.excerpt,c.date_create,c.title
    from _post_comments a,_user_users b,_post_contents c 
          where a.user_id=b.id and a.post_id=c.id
    order by a.id asc limit $start,$pagesize";
    
    $result=$db->query($sql);
    echo "<table width=\"100%\" cellspacing=0><tr><th>Time</th><th>Comment</th><th>from</th><th>News Title</th><th>Action</th></tr>";
    while($row=$db->fetch_array($result)){
        extract($row);
        echo "<tr><td>$comment_create</td><td>$comment</td><td>$fullname</td><td>";
        echo "<a href=\"?mod=posting&action=detail&id=$post_id\">[$title]</a> </td>
        <td align=\"center\"><a id=\"reply_$id\" 
        href=\"?mod=posting&action=reply&reply_id=$id&post_id=$post_id\">
        <img class=icon src=\"images/ic_reply.png\" title=\"Reply Comment\"/></a>
        </td></tr>\r\n";
        
    }
    echo "</table>";
}
switch($action){
    case 'add_process':
        add_process();
        break;
    case 'add':
        add_form();
        break;
    case 'edit':
        edit_form();
        break;
    case 'edit_process':
        edit_process();
        break;
    case 'delete':
        delete();
        break;
    default:
        list_table();
        break;
}
?>